
/* 浅拷贝 */
const $copy = Object.assign;

/* 
  //严格类型判断
  $toClass(key:any);
*/
function $toClass(key) {
  return Object.prototype.toString.call(key).split(" ")[1].replace("]", "");
}
/* 
  //类型判断函数 
  $isType(target:any,type:any);
*/
function $isType(target, type) {
  let targetType = $toClass(target);
  return targetType === type;
}
/* 
  // 判断对象是否具有某个属性
  $hasOwn(obj:Object,key:String);
*/
function $hasOwn(obj,key){
  if( obj && $isType(obj,"Object") ){
    return Object.hasOwnProperty.call(obj,key);
  }else{
    throw new Error("the obj params classType is not a Object");
  }
}
/* 
  //字符串除去空格 
  $trimAll(str:String);
*/
function $trimAll(str) {
  if (str) {
      return str.replace(/\s/gm, "");
  } else {
      return str;
  }
}

module.exports = {
  $copy
  ,$toClass
  ,$isType
  ,$hasOwn
  ,$trimAll
}